package cn.scau.server.controller;


import cn.scau.server.dto.ProcessDetailDTO;
import cn.scau.server.dto.ProcessReceiveDTO;
import cn.scau.server.pojo.ProcessNode;
import cn.scau.server.service.ProcessInfoService;
import cn.scau.server.vo.ResultVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 代码不跑我先跑
 * @since 2025-03-30
 */
@RestController
@RequestMapping("/process")
public class ProcessController {

    @Autowired
    private ProcessInfoService processInfoService;

    @ApiOperation("流程类型增加")
    @PostMapping("/add")
    public ResultVO add(@RequestBody ProcessReceiveDTO processReceiveDTO) {
        return processInfoService.addProcess(
                processReceiveDTO.getProcessType(),
                processReceiveDTO.getApplicationItems(),
                processReceiveDTO.getProcessNodes());
    }

    @ApiOperation("流程类型列表获取")
    @GetMapping("/getProcessTypeList")
    public ResultVO getProcessTypeList() {
        return processInfoService.getProcessTypeList();
    }

    @ApiOperation("某种类型的详情获取")
    @GetMapping("/getProcessDetail")
    public ResultVO getProcessDetail(@RequestParam Integer processId) {
        return processInfoService.getProcessDetail(processId);
    }

    @ApiOperation("类型详情的修改")
    @PostMapping("/updateProcessDetail")
    public ResultVO updateProcessDetail(@RequestBody ProcessReceiveDTO processReceiveDTO) {
        return processInfoService.updateProcessDetail(processReceiveDTO.getProcessType(),processReceiveDTO.getApplicationItems(),processReceiveDTO.getProcessNodes());
    }

    @ApiOperation("某种类型的删除")
    @DeleteMapping("/deleteProcessType")
    public ResultVO deleteProcessType(@RequestParam Integer processId) {
        return processInfoService.deleteProcessType(processId);
    }
}
